package com.project.controller;

import com.project.bean.DiscussBean;
import com.project.bean.UserBean;
import com.project.service.IDiscussService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("discuss")
public class DiscussController {
    @Autowired
    private IDiscussService service;

    @RequestMapping("add")
    public String add(String title,String contents,int topicId, HttpServletRequest req){
        UserBean userBean=(UserBean)req.getSession().getAttribute("loginUser");

        service.add(new DiscussBean(userBean.getId(),topicId,title,contents));
        return "ok";
    }

    @RequestMapping("getChannel")
    public String getChannel(HttpServletRequest req){
        String info=req.getSession().getAttribute("channelName").toString();
        return info;
    }


}
